home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / TranslationExtensions.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  6.5 KB  |  208 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        TranslationExtensions.h
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1989-1993, 1995, 1997-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __TRANSLATIONEXTENSIONS__
  18. #define __TRANSLATIONEXTENSIONS__
  19.  
  20. #ifndef __MACTYPES__
  21. #include <MacTypes.h>
  22. #endif
  23. #ifndef __FILES__
  24. #include <Files.h>
  25. #endif
  26. #ifndef __QUICKDRAW__
  27. #include <Quickdraw.h>
  28. #endif
  29. #ifndef __COMPONENTS__
  30. #include <Components.h>
  31. #endif
  32.  
  33.  
  34.  
  35. #if PRAGMA_ONCE
  36. #pragma once
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_STRUCT_ALIGN
  48.     #pragma options align=mac68k
  49. #elif PRAGMA_STRUCT_PACKPUSH
  50.     #pragma pack(push, 2)
  51. #elif PRAGMA_STRUCT_PACK
  52.     #pragma pack(2)
  53. #endif
  54.  
  55.  
  56. enum {
  57.     kSupportsFileTranslation    = 1,
  58.     kSupportsScrapTranslation    = 2,
  59.     kTranslatorCanGenerateFilename = 4
  60. };
  61.  
  62.  
  63. /* better names for 4-char codes*/
  64. typedef OSType                             FileType;
  65. typedef ResType                         ScrapType;
  66. typedef unsigned long                     TranslationAttributes;
  67.  
  68. enum {
  69.     taDstDocNeedsResourceFork    = 1,
  70.     taDstIsAppTranslation        = 2
  71. };
  72.  
  73.  
  74.  
  75. struct FileTypeSpec {
  76.     FileType                         format;
  77.     long                             hint;
  78.     TranslationAttributes             flags;                        /* taDstDocNeedsResourceFork, taDstIsAppTranslation*/
  79.     OSType                             catInfoType;
  80.     OSType                             catInfoCreator;
  81. };
  82. typedef struct FileTypeSpec                FileTypeSpec;
  83.  
  84. struct FileTranslationList {
  85.     unsigned long                     modDate;
  86.     unsigned long                     groupCount;
  87.                                                                 /*     unsigned long    group1SrcCount;*/
  88.                                                                 /*     unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec);*/
  89.                                                                 /*  FileTypeSpec    group1SrcTypes[group1SrcCount]*/
  90.                                                                 /*  unsigned long    group1DstCount;*/
  91.                                                                 /*  unsigned long    group1DstEntrySize = sizeof(FileTypeSpec);*/
  92.                                                                 /*  FileTypeSpec    group1DstTypes[group1DstCount]*/
  93. };
  94. typedef struct FileTranslationList        FileTranslationList;
  95. typedef FileTranslationList *            FileTranslationListPtr;
  96. typedef FileTranslationListPtr *        FileTranslationListHandle;
  97.  
  98.  
  99. struct ScrapTypeSpec {
  100.     ScrapType                         format;
  101.     long                             hint;
  102. };
  103. typedef struct ScrapTypeSpec            ScrapTypeSpec;
  104.  
  105. struct ScrapTranslationList {
  106.     unsigned long                     modDate;
  107.     unsigned long                     groupCount;
  108.                                                                 /*     unsigned long        group1SrcCount;*/
  109.                                                                 /*     unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec);*/
  110.                                                                 /*  ScrapTypeSpec        group1SrcTypes[group1SrcCount]*/
  111.                                                                 /*  unsigned long        group1DstCount;*/
  112.                                                                 /*     unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec);*/
  113.                                                                 /*  ScrapTypeSpec        group1DstTypes[group1DstCount]*/
  114. };
  115. typedef struct ScrapTranslationList        ScrapTranslationList;
  116. typedef ScrapTranslationList *            ScrapTranslationListPtr;
  117. typedef ScrapTranslationListPtr *        ScrapTranslationListHandle;
  118. /* definition of callbacks to update progress dialog*/
  119.  
  120. typedef long                             TranslationRefNum;
  121. /*****************************************************************************************
  122. *
  123. * This routine sets the advertisement in the top half of the progress dialog.
  124. * It is called once at the beginning of your DoTranslateFile routine.
  125. *
  126. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  127. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  128. *                            Before returning from DoTranslateFile, you should dispose
  129. *                            of the memory.  (Normally, it is in the temp translation heap
  130. *                            so it is cleaned up for you.)
  131. *
  132. * Exit:    returns            noErr, paramErr, or memFullErr
  133. */
  134. EXTERN_API( OSErr )
  135. SetTranslationAdvertisement        (TranslationRefNum         refNum,
  136.                                  PicHandle                 advertisement)                        TWOWORDINLINE(0x7002, 0xABFC);
  137.  
  138.  
  139. /*****************************************************************************************
  140. *
  141. * This routine updates the progress bar in the progress dialog.
  142. * It is called repeatedly from within your DoTranslateFile routine.
  143. * It should be called often, so that the user will get feedback if he tries to cancel.
  144. *
  145. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  146. *            progress    percent complete (0-100)
  147. *
  148. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  149. *            returns        noErr, paramErr, or memFullErr
  150. */
  151. EXTERN_API( OSErr )
  152. UpdateTranslationProgress        (TranslationRefNum         refNum,
  153.                                  short                     percentDone,
  154.                                  Boolean *                canceled)                            TWOWORDINLINE(0x7001, 0xABFC);
  155.  
  156.  
  157.  
  158. /* ComponentMgr selectors for routines*/
  159.  
  160. enum {
  161.     kTranslateGetFileTranslationList = 0,                        /* component selectors*/
  162.     kTranslateIdentifyFile        = 1,
  163.     kTranslateTranslateFile        = 2,
  164.     kTranslateGetTranslatedFilename = 3,
  165.     kTranslateGetScrapTranslationList = 10,                        /* skip to scrap routines*/
  166.     kTranslateIdentifyScrap        = 11,
  167.     kTranslateTranslateScrap    = 12
  168. };
  169.  
  170.  
  171. /* Routines to implment in a file translation extension*/
  172.  
  173.  
  174. typedef CALLBACK_API( ComponentResult , DoGetFileTranslationListProcPtr )(ComponentInstance self, FileTranslationListHandle translationList);
  175. typedef CALLBACK_API( ComponentResult , DoIdentifyFileProcPtr )(ComponentInstance self, const FSSpec *theDocument, FileType *docType);
  176. typedef CALLBACK_API( ComponentResult , DoTranslateFileProcPtr )(ComponentInstance self, TranslationRefNum refNum, const FSSpec *sourceDocument, FileType srcType, long srcTypeHint, const FSSpec *dstDoc, FileType dstType, long dstTypeHint);
  177. typedef CALLBACK_API( ComponentResult , DoGetTranslatedFilenameProcPtr )(ComponentInstance self, FileType dstType, long dstTypeHint, FSSpec *theDocument);
  178.  
  179. /* Routine to implement in a scrap translation extension*/
  180.  
  181. typedef CALLBACK_API( ComponentResult , DoGetScrapTranslationListProcPtr )(ComponentInstance self, ScrapTranslationListHandle list);
  182. typedef CALLBACK_API( ComponentResult , DoIdentifyScrapProcPtr )(ComponentInstance self, const void *dataPtr, Size dataLength, ScrapType *dataFormat);
  183. typedef CALLBACK_API( ComponentResult , DoTranslateScrapProcPtr )(ComponentInstance self, TranslationRefNum refNum, const void *srcDataPtr, Size srcDataLength, ScrapType srcType, long srcTypeHint, Handle dstData, ScrapType dstType, long dstTypeHint);
  184.  
  185.  
  186.  
  187.  
  188. #if PRAGMA_STRUCT_ALIGN
  189.     #pragma options align=reset
  190. #elif PRAGMA_STRUCT_PACKPUSH
  191.     #pragma pack(pop)
  192. #elif PRAGMA_STRUCT_PACK
  193.     #pragma pack()
  194. #endif
  195.  
  196. #ifdef PRAGMA_IMPORT_OFF
  197. #pragma import off
  198. #elif PRAGMA_IMPORT
  199. #pragma import reset
  200. #endif
  201.  
  202. #ifdef __cplusplus
  203. }
  204. #endif
  205.  
  206. #endif /* __TRANSLATIONEXTENSIONS__ */
  207.  
  208.